/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.dao.hibernate;

import com.click.app.dao.SalaryDao;
import com.click.app.model.Employee;
import com.click.app.model.Salary;
import java.util.List;

/**
 *
 * @author ariel
 */
public class SalaryDaoHibernate extends GenericDaoHibernate<Salary, Long> implements SalaryDao{

    public SalaryDaoHibernate() {
        super(Salary.class);
    }

    public List<Salary> findByEmployee(Employee employee) {
        return getHibernateTemplate().find("from Salary where employee=? order by endDate", employee);
    }

    public Salary findByEmployeePay(Employee employee) {
        List<Salary> ss = getHibernateTemplate().find("from Salary where employee=? AND paged=false order by endDate", employee);
        if(ss == null || ss.size() == 0)
            return null;
        return ss.get(0);
    }

}
